import mockIns from "./mock";
import sphIns from "./sph";
export const getMockList=()=>mockIns.get('/list');
export const getFloors=()=>mockIns.get('/floor');
export const getSort = ()=> mockIns.get("/sort")
export const getBaseCategoryList=()=>sphIns.get("/api/product/getBaseCategoryList");
export const getGoodsList=options=>sphIns.post("/api/list",options);
export const getDetailInfo=skuId=>sphIns.get(`/api/item/${skuId}`);
export const addCart = ({skuId,skuNum}) => sphIns.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
export const getCartList=()=>sphIns.get('/api/cart/cartList')
export const delCartList=skuId=>sphIns.delete(`/api/cart/deleteCart/${skuId}`)
export const switchChecked=({skuId,isChecked})=>sphIns.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
export const switchAllChecked=(skuIdArr=[],isChecked)=>{
    let arr=[];
    skuIdArr.forEach(skuId=>{
        const promise=switchChecked({skuId,isChecked})
        arr.push(promise)
    })
    return Promise.all(arr)
}
export const delChecked=(skuIdArr=[])=>{
    let arr=[];
    skuIdArr.forEach(skuId=>{
        const promise=delCartList(skuId)
        arr.push(promise)
    })
    return Promise.all(arr)
}
export const getCode=(phone)=>sphIns.get(`/api/user/passport/sendCode/${phone}`)
export const register=({phone,password,code})=>sphIns.post('/api/user/passport/register',{phone,password,code})
export const login=({phone,password})=>sphIns.post('/api/user/passport/login',{phone,password})
export const loginout=()=>sphIns.get('/api/user/passport/logout')
export const autoLogin=()=>sphIns.get('/api/user/passport/auth/getUserInfo')
export const getOrderList=({page,limit})=>sphIns.get(`/api/order/auth/${page}/${limit}`)
export const getTradeInfo=()=>sphIns.get('/api/order/auth/trade')
export const getUserAddress=()=>sphIns.get('/api/user/userAddress/auth/findUserAddressList')
export const submitList=(tradeNo,options)=>sphIns.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`,options)
export const getOrderPay=(orderId)=>sphIns.get(`/api/payment/weixin/createNative/${orderId}`)
export const findPayState=(orderId)=>sphIns.get(`/api/payment/weixin/queryPayStatus/${orderId}`)